package com.lpit.controller;

import com.lpit.pojo.Message;
import com.lpit.result.ResponseResult;
import com.lpit.service.impl.PrivateMessageServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/letter")
public class PrivateMessageController {
    @Autowired
    PrivateMessageServiceImpl privateMessageService;

    /**
     * 查看私信
     */
    @GetMapping("/view")
    public ResponseResult<List<Message>> view (Message message){
        return privateMessageService.selectLetters(message);
    }
    /**
     * 删除私信
     */
    @DeleteMapping("/delete")
    public ResponseResult<Integer> delete(Integer id){
        return privateMessageService.deleteLetters(id);
    }

    /**
     * 回复私信
     */
    @PostMapping
    public ResponseResult<List<Message>> insert(Message message){
        return privateMessageService.insertLetters(message);
    }

}
